package com.oreilly.justspring.core.ch2.ex28;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TradeCreatorClient {
	private ApplicationContext ctx = null;

	  public TradeCreatorClient() {
	    ctx = new ClassPathXmlApplicationContext("ch2-beans.xml");
	  }

	  public int createTrade(){
		  Trade t = (Trade) ctx.getBean("trade");
		  return t.getTradeId();
	  }
	  
	public static void main(String[] args) {
		TradeCreatorClient client = new TradeCreatorClient();
		for (int i = 0; i < 10; i ++)
		System.out.println("Trade Id: "+client.createTrade());
	}
}
